package com.example.newYear.mesageObserver;

public class MessagePushSystemExample {

    public static void main(String[] args) {
        //创建消息服务器实例
        MessageServer messageServer = new MessageServer();

        //创建两个客户端消息列表实例，模拟不同用户
        ClientMessageList clientMessageList1 = new ClientMessageList("user1");
        ClientMessageList clientMessageList2 = new ClientMessageList("user2");

        //将客户端消息列表注册到消息服务器作为观察者
        messageServer.registerObserver(clientMessageList1);
        messageServer.registerObserver(clientMessageList2);

        //模拟用户A发送消息给用户B
        Message message = new Message("user1", "user2", "Hello, userB!");
        messageServer.notifyObserver(message);
    }
}
